<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
​
<html>
<head>
    <title>新增书籍</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <%--<script type="text/javascript" src="${pageContext.request.contextPath}/statics/jquery.min.js"></script>
&lt;%&ndash;    <script src="${pageContext.request.contextPath}/statics/jquery-3.4.1.min.js"></script>&ndash;%&gt;
    <script type="text/javascript" src="${pageContext.request.contextPath}/statics/bootstrap.min.js"></script>--%>

    <script>

        (function($){
            $(window).load(function(){

                $("a[rel='load-content']").click(function(e){
                    e.preventDefault();
                    var url=$(this).attr("href");
                    $.get(url,function(data){
                        $(".content .mCSB_container").append(data); //load new content inside .mCSB_container
                        //scroll-to appended content
                        $(".content").mCustomScrollbar("scrollTo","h2:last");
                    });
                });

                $(".content").delegate("a[href='top']","click",function(e){
                    e.preventDefault();
                    $(".content").mCustomScrollbar("scrollTo",$(this).attr("href"));
                });

            });
        })(jQuery);
    </script>
</head>
<body>
<jsp:include page="../book/header.jsp"/>
<section class="rt_wrap content mCustomScrollbar">
    <div class="rt_content">
        <div class="page_title">
            <h2 class="fl">添加会员</h2>
            <a href="adjust_funding.html" class="fr top_rt_btn money_icon">资金管理</a>
        </div>
        <form action="${pageContext.request.contextPath}/user/addUser" method="post"  enctype="multipart/form-data">
            <ul class="ulColumn2">
                <li>
                    <span class="item_name" style="width:120px;">上传头像：</span>
                    <label class="uploadImg">
                        <input type="file" name="file"/>
                        <span>上传头像</span>
                    </label>
                </li>
                <li>
                    <span class="item_name" style="width:120px;">用户名：</span>
                    <input type="text" class="textbox textbox_225" value="" placeholder="会员账号..." name="userName" onblur="username()" id="userName"/>
                    <span id="errorTips"></span>
                </li>
                <li>
                    <span class="item_name" style="width:120px;">登陆密码：</span>
                    <input type="password" class="textbox textbox_225" value="" placeholder="会员密码..." name="password"/>
                </li>
                <li>
                    <span class="item_name" style="width:120px;">会员等级：</span>
                    <select class="select">
                        <option>普通会员</option>
                    </select>
                    <input type="hidden" value="0" name="type">
                </li>
                <li>
                    <span class="item_name" style="width:120px;">用户昵称：</span>
                    <input type="text" class="textbox textbox_225" value="" placeholder="用户昵称..." name="nickname"/>
                </li>

                <li>
                    <span class="item_name" style="width:120px;"></span>
                    <input type="submit" class="link_btn" value="添加"/>
                </li>
            </ul>
        </form>
    </div>
</section>
<%--<div class="container">
    ​
    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="page-header">
                <h1>
                    <small>添加用户</small>
                </h1>
            </div>
        </div>
    </div>
    <form action="${pageContext.request.contextPath}/user/addUser" method="post">
        用户头像：<input type="text" name="avatar"><br><br><br>
        用户名：<input type="text" name="userName"><br><br><br>
        用户密码：<input type="text" name="password"><br><br><br>
        用户昵称：<input type="text" name="nickname"><br><br><br>
        用户类型：<select name="type"><option value="1">普通用户</option><option value="2">管理员</option></select><br><br><br>
        <input type="submit" class="btn btn-primary btn-lg" value="提交"/>
    </form>
        ​
</div>--%>
<script>
    function username() {
        var username = document.getElementById("userName");
        $.ajax({
            url:"${pageContext.request.contextPath}/user/queryUserByUserName",
            type:"POST",
            dataType:"Json",
            data:{userName:username.value},
            success:function (data) {
                if (data.length > 0){
                    var errorTips = document.getElementById("errorTips");
                    errorTips.innerText = "该用户已存在，请更换"
                }
            }
        })
    }
</script>
</body>
</html>
